import {
	post,
	get,
	put,
} from '@/utils/request.js'

/**
 * 首页活动列表
 */
export const pageIndexActiveApi = (params) => {
	return get('/active/pageIndexActive', params)
}

/**
 * 活动详情
 */
export const activeDetailsApi = (id,code) => {
	return get(`/active/details?id=${id}&shareCode=${code}`)
}

/**
 * 活动收藏/取消收藏
 */
export const activeCollectUpdateStateApi = (data) => {
	return put('/activeCollect/updateState', data)
}

/**
 * 获取商户的联系方式（只限于团购活动的非多商户商品）
 */
export const getCustomInfoApi = (merchantId) => {
	return get(`/active/getCustomInfo?merchantId=${merchantId}`)
}

/**
 * 获取商品券的使用说明和可用商户
 */
export const getUseDetailsApi = (data) => {
	return get(`/active/useDetails`, data)
}

/**
 * 关联商户列表（供添加活动商品调用）
 */
export const getRelationMerchantApi = (data) => {
	return get(`/business/pageRelationMerchant`, data)
}

/**
 * 创建活动选择商品列表
 */
export const getGoodsActiveApi = (data) => {
	return get('/goods/pageGoodsActive', data)
}

/**
 * 红包领取列表
 */
export const redPacketListApi = (data) => {
	return get('/activeRedPacket/pageReceive', data)
}

/**
 * 领取红包
 */
export const receivePedPacketApi = (data) => {
	return post('/activeRedPacket/receive', data)
}

/**
 * 活动预分享
 */
export const activePreShareApi = (data) => {
	return post('/businessActive/preShare', data)
}

/**
 * 活动分享
 */
export const activeShareApi = (data) => {
	return post('/businessActive/share', data)
}

/**
 * 生成short link
 */
export const generateShortLinkApi = (data) => {
	return post('/businessActive/generateShortLink', data)
}


/**
 * 前端活动时间倒计时到了调用,更新活动状态=已结束
 */
export const activeUpdateEnd = (data) => {
	return post('/active/updateEnd', data, { hideErrorToast: true })
}

/**
 * 分销排行
 */
export const agentRankApi = (data) => {
	return get('/active/agentRank', data)
}

/**
 * 活动可用红包列表
 */
export const availableRedPacketListApi = (data) => {
	return get('/active/availableRedPacketList', data)
}

/**
 * 为你推荐（订单、活动底部）
 */
export const recommendByBusinessIdApi = (params) => {
	return get('/active/recommendByBusinessId', params)
}